from fastapi import FastAPI

app = FastAPI()

import os

@app.get("/")
async def root():
    # pip install psutil
    import psutil

    # 获取所有网络接口的信息
    network_interfaces = psutil.net_if_addrs()

    # 打印网卡信息
    info_list = []
    for interface_name, interface_data in network_interfaces.items():
        print(f"Interface: {interface_name}")
        for data in interface_data:
            t_data = f"  {data.family}: {data.address}"
            info_list.append(t_data)

    return {"message": "Hello World","info":info_list}
